package net.zjitc.controller;

import net.zjitc.pojo.Order;
import net.zjitc.service.OrderService;
import net.zjitc.service.impl.OrderServiceImpl;
import net.zjitc.utils.dispacher.URLMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by tt on 2017/12/23.
 */
public class AdminOrder {
    OrderService orderService=new OrderServiceImpl();
    //所有订单
    @URLMapping(url = "/adminOrder")
    public String adminOrder(HttpServletRequest request, HttpServletResponse response){
        /*int page=Integer.valueOf(request.getParameter("page"));
        int pageSize=12;*/
        List<Order> list=orderService.findAll();
        request.setAttribute("olist",list);
        return "/admin/order/orders.jsp";
    }
    //根据订单状态查找订单
    @URLMapping(url = "/adminOrder_findByState")
    public String adminOrder_findByState(HttpServletRequest request, HttpServletResponse response){
        int state=Integer.valueOf(request.getParameter("state"));
        List<Order> list=orderService.findbyState(state);
        request.setAttribute("olist",list);
        return "/admin/order/orders.jsp";
    }
    //发货
    @URLMapping(url = "/adminOrder_editState")
    public String adminOrder_editState(HttpServletRequest request, HttpServletResponse response){
        String oid=request.getParameter("oid");
        int count=orderService.editState(oid);
        //查询所有已发货列表
        int state=3;
        List<Order> list=orderService.findbyState(state);
        request.setAttribute("olist",list);
        return "/admin/order/orders.jsp";
    }
}
